﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Data.SqlClient;
using WindowsFormsApplication1;

namespace DA_CNPM
{
    public partial class formThemsach : Form
    {
        Database database = new Database();
        public formThemsach()
        {
            InitializeComponent();
            database.conn.Open();
        }

        private void btOk_Click(object sender, EventArgs e)
        {
            String tensach = tbTensach.Text;
            String masach = tbMasach.Text;
            String nhaxuatban = tbNhaxuatban.Text;
            String namxuatban = tbNamxuatban.Text;

            String tacgia = tbTacgia.Text;
            String matacgia = tbmatacgia.Text;
            String chucvu = tbchucvu.Text;

            String sql = "INSERT INTO sach(masach,tensach,namxuatban,nhaxuatban,tinhtrang) VALUES ('" + masach + "','" + tensach + "','" + namxuatban + "','" + nhaxuatban + "','1')";
            SqlCommand cmd = new SqlCommand(sql, database.conn);
            cmd.ExecuteNonQuery();

            String sql1 = "INSERT INTO tacgia(matacgia,tentacgia,chucvu) VALUES ('" + matacgia + "','" + tacgia + "','" + chucvu + "')";
            SqlCommand cmd1 = new SqlCommand(sql1, database.conn);
            cmd1.ExecuteNonQuery();

            String sql2 = "INSERT INTO tacgia_sach(matacgia,masach) VALUES ('" + matacgia + "','" + masach + "')";
            SqlCommand cmd2 = new SqlCommand(sql2, database.conn);
            cmd2.ExecuteNonQuery();

            this.Close();
        }
    }
}
